package com.cans.base.dto;

import java.io.Serializable;

/**
 * Auther: shencan
 * Date: 2017/10/3
 * Description: controller层传输类
 */
public class ResDto<T> implements Serializable{

    public static final int SUCCESS = 1;
    public static final int FAIL = 0;

    /**
     * 是否成功
     */
    private Integer status;

    /**
     * 错误信息
     */
    private String message;

    /**
     * 返回结构
     */
    private T data;

    public static <T>ResDto<T> success(T t){
        ResDto res = new ResDto();
        res.setStatus(SUCCESS);
        res.setData(t);
        return res;
    }
    public static <T>ResDto<T> success(){
        ResDto res = new ResDto();
        res.setStatus(SUCCESS);
        return res;
    }
    public static <T>ResDto<T> fait(String message){
        ResDto res = new ResDto();
        res.setStatus(FAIL);
        res.setMessage(message);
        return res;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
